//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tyr_repair\fn_updateActions.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_unit","_activated"];
DEFAULT_PARAM(_unit,0,objNull);
DEFAULT_PARAM(_activated,1,false);

// GVAR(Repair_Action_Id) = -1;
// GVAR(Analyze_Action_Id) = -1;
//addAction ["Hint Hello!", {hint format ["Hello %1!", _this select 3]}, [], 1, false, true, "", "true"];

if (GVAR(Repair_Action_Id) <= 0 && _activated && GVAR(Target_CanRepair)) then {
	GVAR(Repair_Action_Id) = _unit addAction [BLUE_TEXT(localize "STR_TYR_REPAIR_ACTION"),{createDialog "TYR_REPAIR_request_ui"; 0 spawn {waituntil {!alive player || !dialog}; GVAR(Repairing) = false;}}, [], 100, false, true, "", "alive _target && !TYR_REP_Repairing"];
};

if (GVAR(Repair_Action_Id) >= 0 && (!_activated || !GVAR(Target_CanRepair))) then {
	_unit removeAction GVAR(Repair_Action_Id);
	GVAR(Repair_Action_Id) = -1;
};

TRACE("End");
TMFPROFILERSTOP;
